package cn.anline.ann_wp.utils

import android.content.Context

/**
 * Created by luozh on 2017/7/12.
 */
class SPUtil(){
    private fun getPacName(context: Context): String {
        return context.packageName
    }

    fun put(context: Context, key: String, value: Boolean) {
        val sp = context.getSharedPreferences(getPacName(context), Context.MODE_PRIVATE)
        val editor = sp.edit()
        editor.putBoolean(key, value)
        editor.commit()
    }

    operator fun get(context: Context, key: String, defaultValue: Boolean): Boolean {
        val sp = context.getSharedPreferences(getPacName(context), Context.MODE_PRIVATE)
        return sp.getBoolean(key, defaultValue)
    }
}